package com.example.dangerouscargodriver.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;

import com.handmark.pulltorefresh.library.PullToRefreshScrollView;
import com.handmark.pulltorefresh.library.PullToRefreshScrollViewWithListener;

/**
 * Created by yechao on 2019/1/23.
 * Describe : 带滑动监听的scrollview
 */
public class BJPullToRefreshScrollView extends PullToRefreshScrollViewWithListener
    implements PullToRefreshScrollViewWithListener.ScrollViewListener{

    public interface ScrollViewListener {
        void onScrollChanged(int x, int y, int oldx, int oldy);
    }

    private ScrollViewListener scrollViewListener = null;

    public BJPullToRefreshScrollView(Context context) {
        super(context);
        setScrollViewListener(this);
    }

    public BJPullToRefreshScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
        setScrollViewListener(this);
    }

    public void setScrollViewListener(ScrollViewListener scrollViewListener) {
        this.scrollViewListener = scrollViewListener;
    }

    @Override
    public void onScrollChanged(int x, int y, int oldx, int oldy) {
        if (scrollViewListener != null) {
            scrollViewListener.onScrollChanged(x, y, oldx, oldy);
        }
    }
}
